/**
 * @project readnote
 * @Title BookAction.java
 * @author huxh
 * @date 2012-2-12
 **/
package com.readnote.common.top.action;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.cr.backbone.action.AppBaseActionSupport;
import com.readnote.book.model.Book;
import com.readnote.book.service.BookService;

public class AllUserNoteAction extends AppBaseActionSupport{
	
	private Book book;
	private Collection<Book> books;
	private BookService bookService;
	private Date createTime;
	
	public String index(){
		
		System.out.println(getQuery().getQuery());
		page = bookService.getPage(getQuery(),page);
		return INDEX;
	}
	
	private Map<String,String> temp;
	public Map<String, String> getTemp() {
		return temp;
	}

	public void setTemp(Map<String, String> temp) {
		this.temp = temp;
	}

	public String input(){
		System.out.println(createTime);
		if(book!=null && !book.isNullRow())
			book = bookService.get(book.getId());
		return INPUT;
	}
	
	public String save(){
		if(book.isNullRow()){
			bookService.save(book);
		}else{
			
			bookService.update(book);
		}
		return SUCCESS;
	}
	
	public String delete(){
		bookService.delete(book);
		return SUCCESS;
	}

	
	
	
	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public BookService getBookService() {
		return bookService;
	}

	public void setBookService(BookService bookService) {
		this.bookService = bookService;
	}

	public Collection<Book> getBooks() {
		books =bookService.getList();
		return books;
	}

	public void setBooks(List<Book> books) {
		this.books = books;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	
}
